{$CLEO .qa}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "GLSCRQA"

// By ArtemQa146

const
    ped_1 = 31@
    ped_2 = 30@
    ped_3 = 29@
    progress = 27@
    x1 = 26@
    y1 = 25@
    z1 = 24@
    a1 = 23@
    obj_1 = 22@
    render_obj = 21@
    event = 20@
end

0087: x1 = 0@ // (float)
0087: y1 = 1@ // (float)
0087: z1 = 2@ // (float)
0087: a1 = 3@ // (float)

if
    0E4D: random_percent 40
then
else
    repeat
    wait 0
    until not locate_char_distance_to_coordinates $PLAYER_ACTOR pos x1 y1 z1 radius 150.0
    0A93: terminate_this_custom_script
end



            repeat
            wait 0
            04ED: load_animation  "PedEventsMod"
            until 04EE:   animation "PedEventsMod" loaded

            model.Load(27)
            model.Load(260)
            model.Load(1649)
            model.Load(153)
            if
                not model.Available(27)
            then
                repeat
                wait 0
                model.Load(27)
                until model.Available(27)
            end
            if
                not model.Available(260)
            then
                repeat
                wait 0
                model.Load(260)
                until model.Available(260)
            end
            if
                not model.Available(1649)
            then
                repeat
                wait 0
                model.Load(1649)
                until model.Available(1649)
            end
            if
                not model.Available(153)
            then
                repeat
                wait 0
                model.Load(153)
                until model.Available(153)
            end
            038B: load_requested_models


            009A: ped_1 = create_actor_pedtype 21 model 27 at x1 y1 z1
            0173: set_actor ped_1 Z_angle_to a1
            0E24: fix_char ped_1 ground 1 brightness 1 and_fade_in 0
            0812: AS_actor ped_1 perform_animation "glasscr2" IFP "PedEventsMod" framedelta 100.0 loopA 1 lockX 0 lockY 0 lockF 1 time -1  // versionB

            04C4: store_coords_to 1@ 2@ 3@ from_actor ped_1 with_offset 0.0 5.0 0.0
            009A: ped_2 = create_actor_pedtype 21 model 260 at 1@ 2@ 3@
            0172: 1@ = actor ped_1 Z_angle
            1@ += 180.0
            0173: set_actor ped_2 Z_angle_to 1@
            0E24: fix_char ped_2 ground 1 brightness 1 and_fade_in 0
            0812: AS_actor ped_2 perform_animation "glasscr" IFP "PedEventsMod" framedelta 100.0 loopA 1 lockX 0 lockY 0 lockF 1 time -1  // versionB
            
            04C4: store_coords_to 1@ 2@ 3@ from_actor ped_1 with_offset 1.2 0.65 0.0
            009A: ped_3 = create_actor_pedtype 21 model 153 at 1@ 2@ 3@
            0172: 1@ = actor ped_1 Z_angle
            1@ += 90.0
            0173: set_actor ped_3 Z_angle_to 1@
            0E24: fix_char ped_3 ground 1 brightness 1 and_fade_in 0
            0812: AS_actor ped_3 perform_animation "crime_c2" IFP "PedEventsMod" framedelta 100.0 loopA 1 lockX 0 lockY 0 lockF 1 time -1  // versionB
            0AF0: 1@ = read_int_from_ini_file "cleo\PedsModels.ini" section "Models" key "cop2"
            0F02: create_render_object_to_char_bone_from_special ped_3 special_model 1@ bone 34 offset 0.25 0 0 rotation 0 180.0 350.0 store_to 2@
            
            04C4: store_coords_to 1@ 2@ 3@ from_actor ped_1 with_offset 0.0 2.5 -0.6
            0E01: create_object_no_save 1649 at 1@ 2@ 3@ offset 0 ground 0 to obj_1
            0172: 1@ = actor ped_1 Z_angle
            1@ += 90.0
            0177: set_object obj_1 Z_angle_to 1@
            0F03: create_render_object_to_object obj_1 model 1649 offset 0 0.0 0.8 rotation 0 0 0 store_to render_obj
            0E37: set_render_object_scale render_obj 0.95 0.8 0.7
            08D2: object obj_1 scale_model 0.0

            model.Destroy(27)
            model.Destroy(260)
            model.Destroy(153)
            model.Destroy(1649)

            1@ = 0
            timera = 0
            progress = 0
            event = 0
            
            repeat
            wait 0
            if and
                056D:   actor ped_1 defined
                056D:   actor ped_2 defined
                056D:   actor ped_3 defined
                03CA:   object obj_1 exists
            then
            
                if
                    progress == 1
                then
                    1@ = 0.0
                    2@ = 0.0
                    3@ = 0.8
                    0687: clear_actor ped_1 task
                    0687: clear_actor ped_2 task
                    0687: clear_actor ped_3 task
                    repeat
                    wait 0
                    if
                        03CA:   object obj_1 exists
                    then
                        1@ += 0.1
                        3@ -= 0.05
                        0087: 2@ = 1@ // (float)
                        2@ *= 10.0
                        2@ *= 5.5
                        2@ *= -1.0
                        0E35: set_render_object_position render_obj 0.0 1@ 3@
                        0E36: set_render_object_rotation render_obj 2@ 0.0 0.0
                        if
                            1@ >= 1.5
                        then
                            progress = 2
                            0723: break_object obj_1 intensity 1
                            break
                        end
                    else
                        break
                    end
                    until not player.Defined(0)
                    continue
                end
                
                if and
                    event == 1
                    progress == 2
                then
                    01C2: remove_references_to_actor ped_1 // Like turning an actor into a random pedestrian
                    01C2: remove_references_to_actor ped_2 // Like turning an actor into a random pedestrian
                    01C2: remove_references_to_actor ped_3 // Like turning an actor into a random pedestrian
                    if 056D:   actor ped_1 defined
                    then 05E2: AS_actor ped_1 kill_actor $PLAYER_ACTOR
                    end
                    if 056D:   actor ped_2 defined
                    then 05E2: AS_actor ped_2 kill_actor $PLAYER_ACTOR
                    end
                    if 056D:   actor ped_3 defined
                    then 05E2: AS_actor ped_3 kill_actor $PLAYER_ACTOR
                    end
                    01C4: remove_references_to_object obj_1 // This object will now disappear when the player looks away
                    break
                end
                
                if and
                    event == 0
                    progress == 2
                then
                    break
                end

                if
                    not locate_char_distance_to_coordinates $player_actor pos x1 y1 z1 radius 120.0
                then
                    break
                end

                if
                    progress == 0
                then
                    if or
                        0118:   actor ped_1 dead
                        0118:   actor ped_2 dead
                        0118:   actor ped_3 dead
                    then
                        progress = 1
                        continue
                    end


                    if or
                        051A:   actor ped_1 damaged_by_actor $PLAYER_ACTOR
                        051A:   actor ped_2 damaged_by_actor $PLAYER_ACTOR
                        051A:   actor ped_3 damaged_by_actor $PLAYER_ACTOR
                    then
                        event = 1
                        progress = 1
                        continue
                    end

                    0A98: 1@ = object obj_1 struct
                    0D4E: 2@ = read_struct 1@ offset 0x140 size 4
                    if or
                        08B7:   test 2@ bit 10 // The object is broken
                        08B7:   test 2@ bit 6 // The object is expl
                        08B7:   test 2@ bit 5 // The object is expl
                    then
                        event = 1
                        progress = 2
                        continue
                    end

                    080E: get_actor ped_1 ped_event_to 1@
                    080E: get_actor ped_2 ped_event_to 2@
                    080E: get_actor ped_3 ped_event_to 3@
                    if or
                        1@ == 49
                        1@ == 9
                        2@ == 49
                        2@ == 9
                        3@ == 49
                        3@ == 9
                    then
                        progress = 1
                        continue
                    end
                    
                    080E: get_actor ped_1 ped_event_to 1@
                    080E: get_actor ped_2 ped_event_to 2@
                    if or
                        1@ == 15
                        1@ == 31
                        1@ == 59
                        2@ == 15
                        2@ == 31
                        2@ == 59
                    then
                        progress = 1
                        continue
                    end
                    
                    080E: get_actor ped_3 ped_event_to 1@
                    if or
                        1@ == 15
                        1@ == 31
                        1@ == 59
                    then
                        progress = 1
                        continue
                    end

                    if
                        0EE6: locate_char_distance_to_object $PLAYER_ACTOR object obj_1 radius 30.0
                    then
                        if or
                            0457:   player $PLAYER_CHAR aiming_at_actor ped_1
                            0457:   player $PLAYER_CHAR aiming_at_actor ped_2
                            0457:   player $PLAYER_CHAR aiming_at_actor ped_3
                        then
                            0E83: get_current_char_weaponinfo $PLAYER_ACTOR store_to 1@
                            0E89: get_weaponinfo_fire_type 1@ store_to 2@ //     
                            if or
                                2@ == 1 //  
                                2@ == 3 //   (  ..)
                            then
                                if
                                    timera > 1000
                                then
                                    event = 1
                                    progress = 1
                                    continue
                                end
                            else
                                timera = 0
                            end
                        else
                            timera = 0
                        end
                    end
                end

            else
                break
            end
            until not player.Defined(0)
            if 056D:   actor ped_1 defined
            then 01C2: remove_references_to_actor ped_1 // Like turning an actor into a random pedestrian
            end
            if 056D:   actor ped_2 defined
            then 01C2: remove_references_to_actor ped_2 // Like turning an actor into a random pedestrian
            end
            if 056D:   actor ped_3 defined
            then 01C2: remove_references_to_actor ped_3 // Like turning an actor into a random pedestrian
            end
            if 03CA:   object obj_1 exists
            then 01C4: remove_references_to_object obj_1 // This object will now disappear when the player looks away
            end
            04EF: release_animation "PedEventsMod"
            repeat
            wait 0
            until not locate_char_distance_to_coordinates $player_actor pos x1 y1 z1 radius 120.0
            0A93: terminate_this_custom_script


0A93: terminate_this_custom_script
